package com.laobiao.paChong.wanyijunshi;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.laobiao.paChong.wanyijunshi.util.HttpClientUtil;
/**
 * 测试网易军事频道
 * @author laobiao
 *
 */
public class testClient {

	@Test
	public void test1(){
		Map<String, String> headers=new HashMap<>();
		headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36");
		headers.put("Accept-Language", "zh-CN,zh;q=0.8");
		headers.put("Accept-Encoding", "gzip, deflate");
		String s=HttpClientUtil.sendGetRequest("http://temp.163.com/special/00804KVA/cm_war_02.js?callback=data_callback", null,headers,"GBK");
		//                                      http://temp.163.com/special/00804KVA/cm_war.js?callback=data_callback
		//System.out.println(s);
		s=s.substring("data_callback(".length(), s.length()-1);
		//System.out.println(s);
		JSONArray arr = JSONArray.parseArray(s);
	
		if(arr!=null && !arr.isEmpty()){
			int arrSize = arr.size();
			for (int x=0;x<arrSize;x++) {
				String title = arr.getJSONObject(x).getString("title");
				System.out.println(title);
			}
		}
			
	}
	
}
